﻿using System;
using System.Collections.Generic;
using Budgetsch.Web.EntityModel;
using Budgetsch.Web.Services;
using GalaSoft.MvvmLight;

namespace Budgetsch.ViewModels.Incomes
{
    public abstract class IncomeDetailVMBase : ViewModelBase
    {
        protected readonly BudgetschDomainContext m_context;

        public IEnumerable<IncomeCategory> Categories { get; set; }

        private Income m_Income;
        public const string NewIncomePropertyName = "Income";
        public Income Income
        {
            get
            {
                return m_Income;
            }

            set
            {
                if (m_Income == value)
                {
                    return;
                }

                m_Income = value;
                RaisePropertyChanged(() => Income);
            }
        }

        protected IncomeDetailVMBase(BudgetschDomainContext context_)
        {
            m_context = context_;
            m_context.Load(m_context.GetIncomeCategoriesWithItemsQuery());
            Categories = m_context.IncomeCategories;
        }

        public abstract void Commit();
    }
}